#!/bin/bash

cd ..
echo "开始导出客户端协议--------------"
npm run export-proto:all
if [ $? -eq 0 ]; then
    echo "客户端协议导出成功------------"
else
    echo "error: 客户端协议导出失败============"
    exit 1
fi

echo "\n"

serverRoot=../server
if [ ! -d $serverRoot ]; then
    echo "服务器目录不存在，跳过服务器协议导出"
    exit 1
fi

cd $serverRoot
echo "开始导出服务器协议--------"
lua export_proto.lua $@
if [ $? -eq 0 ]; then
    echo "服务器协议导出成功------------"
else
    echo "error: 服务器协议导出失败============"
    exit 1
fi